/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.globallogic.webapp.javaclasses;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author kostiantyn.baranov
 */
/**
 * @author kostiantyn.baranov
 * 
 */
public class Users {

	static Map<String, String> users = new HashMap<String, String>();

	public void addUser(String login, String inputPassword) {
		this.users.put(login, this.md5(inputPassword));
	}

	public String md5(String inputPass) {
		if (inputPass == null) {
			throw new NullPointerException();
		}
		String hash = null;
		try {
			MessageDigest m = MessageDigest.getInstance("MD5");
			m.update(inputPass.getBytes(), 0, inputPass.length());
			hash = new BigInteger(1, m.digest()).toString(16);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return hash;
	}

	public Map<String, String> getUsers() {
		return users;
	}

}
